//
// Created by XML on 2023/9/17.
//
#include <stdio.h>
#include <stdbool.h>
int main() {

    // 循环语句：while(..){}  do{}while(..)  for(;;)


#define ADD '+'
#define SUB '-'
#define MULTIPLY '*'
#define DIVIDE '/'
#define REM '%'

    int left;
    int right;

    char operator;
    char command = 'y';
    printf("command: %d\n",command);
    printf("command: %c\n",command);
    printf("command: %d\n",command!='q');
    do{
        printf("Please input an expression: \n");
        scanf("%d %c %d",&left,&operator,&right);
        int result;
        switch (operator) {
            case ADD:
                result = left + right;
                break;
            case SUB:
                result = left - right;
                break;
            case MULTIPLY:
                result = left * right;
                break;
            case DIVIDE:
                result = left / right;
                break;
            case REM:
                result = left % right;
                break;
            default:
                result = 0;
                printf("error %c\n",operator);
                break;
        }
        printf("result: %d\n",result);
        getchar();
        command = getchar();
        printf("command: %d\n",command);
    }while (command != 'q');


    return 0;
}